<?php
declare (strict_types=1);

namespace app\controller\admin;

use app\common\controller\BaseController;
use app\model\admin\Notice as noticeModel;
use think\App;
use \Throwable;

class Notice extends BaseController
{
    protected $model;

    public function __construct(App $app, noticeModel $model)
    {
        parent::__construct($app);
        $this->model = $model;
    }

    /**
     * 显示内容
     * @return array
     */
    public function detail()
    {
        $info = $this->model->getOne($this->params);
        return $this->returnRight($info);
    }

    /**
     * 编辑
     * PUT    blog/:id
     * @return array
     */
    public function update()
    {
        try {
            $field = 'id,notice_type,notice_content';
            return $this->model->edit($this->params, $field);
        } catch (Throwable $ex) {
            return $this->returnException($ex);
        }
    }
}
